<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Set 实践</title>
</head>
<body>
    <script>
        let set = [1,2,2,3,4,6,4,7,8];
        //去重
       // let result = [...new Set(set)];
       // console.log(result);
        //交集
        let set2 = [1,1,3,4,9,10];
        // let result = [... new Set(set)].filter(item=>{
        //    return new Set(set2).has(item);
        // });
        // console.log(result);
        //并集
        let union = [...new Set([...set,...set2])];
        console.log(union);
        //差集
        let resul = [...new Set(set)].filter(item=>  !new Set(set2).has(item));
        console.log(resul);

    </script>
</body>
</html>